package com.jimmy.sms.common.config;

import com.jimmy.sms.common.properties.SmsProperties;
import com.jimmy.sms.common.service.impl.AliyunSmsSenderImpl;
import com.jimmy.sms.common.service.impl.TencentSmsSenderImpl;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author create by jimmy 2116398125@qq.com
 * @package com.jimmy.sms.common.config
 * @date 2024/5/15 9:40 PM
 */
@Configuration
@EnableConfigurationProperties(value = SmsProperties.class)
public class SmsAutoConfiguration {
    /**
     *  阿里云发送短信的实现类
     * @param smsProperties
     * @return
     */
    @Bean
    public AliyunSmsSenderImpl aliYunSmsSender(SmsProperties smsProperties) {
        return new AliyunSmsSenderImpl(smsProperties.getAliYun());
    }

    /**
     * 腾讯云发送短信的实现类
     * @param smsProperties
     * @return
     */
    @Bean
    public TencentSmsSenderImpl tencentSmsSender(SmsProperties smsProperties) {
        return new TencentSmsSenderImpl(smsProperties.getTencent());
    }
}
